﻿using System;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace WAD.DAL
{
    public class DAOLog : DAO
    {
        public static int Add(string msg, int adminid, int user_id = 0)
        {
            String sql = string.Format("insert into log(user_id,adminid,msg,date)values(@user_id,@adminid,@msg,@date)");
            Database db = GetDatabase();
            DbCommand cmd = db.GetSqlStringCommand(sql);
            db.AddInParameter(cmd, "@user_id", DbType.String, user_id);
            db.AddInParameter(cmd, "@adminid", DbType.Int32, adminid);
            db.AddInParameter(cmd, "@msg", DbType.String, msg);
            db.AddInParameter(cmd, "@date", DbType.DateTime, DateTime.Now);
            return db.ExecuteNonQuery(cmd);

        }
    }
}